// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()

// 云函数入口函数
exports.main = async (event, context) => {
  let { id } = event
  var success = false
  var message = "审核失败"
  const db = cloud.database()

  console.log('id',id)

  await db.collection('absence-list').where({
    _id: id
  }).update({
    data: {
      approved: true
    }
  }).then(res => {
    success = true
    message = "审核成功"
  }, error => {
    success = false
    message = "审核失败"
  })
  return {
    success: success,
    message: message
  }
}